/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tbv_maquina_tbv_ruta_programadaDAOImpl implements orm.dao.Tbv_maquina_tbv_ruta_programadaDAO {
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByORMID(int id_maquina_ruta_programada) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_maquina_tbv_ruta_programadaByORMID(session, id_maquina_ruta_programada);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada getTbv_maquina_tbv_ruta_programadaByORMID(int id_maquina_ruta_programada) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_maquina_tbv_ruta_programadaByORMID(session, id_maquina_ruta_programada);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByORMID(int id_maquina_ruta_programada, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_maquina_tbv_ruta_programadaByORMID(session, id_maquina_ruta_programada, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada getTbv_maquina_tbv_ruta_programadaByORMID(int id_maquina_ruta_programada, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_maquina_tbv_ruta_programadaByORMID(session, id_maquina_ruta_programada, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByORMID(PersistentSession session, int id_maquina_ruta_programada) throws PersistentException {
		try {
			return (Tbv_maquina_tbv_ruta_programada) session.load(orm.Tbv_maquina_tbv_ruta_programada.class, new Integer(id_maquina_ruta_programada));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada getTbv_maquina_tbv_ruta_programadaByORMID(PersistentSession session, int id_maquina_ruta_programada) throws PersistentException {
		try {
			return (Tbv_maquina_tbv_ruta_programada) session.get(orm.Tbv_maquina_tbv_ruta_programada.class, new Integer(id_maquina_ruta_programada));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByORMID(PersistentSession session, int id_maquina_ruta_programada, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_maquina_tbv_ruta_programada) session.load(orm.Tbv_maquina_tbv_ruta_programada.class, new Integer(id_maquina_ruta_programada), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada getTbv_maquina_tbv_ruta_programadaByORMID(PersistentSession session, int id_maquina_ruta_programada, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_maquina_tbv_ruta_programada) session.get(orm.Tbv_maquina_tbv_ruta_programada.class, new Integer(id_maquina_ruta_programada), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada[] listTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada[] listTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada[] listTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_maquina_tbv_ruta_programada as Tbv_maquina_tbv_ruta_programada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tbv_maquina_tbv_ruta_programada[]) list.toArray(new Tbv_maquina_tbv_ruta_programada[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada[] listTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_maquina_tbv_ruta_programada as Tbv_maquina_tbv_ruta_programada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tbv_maquina_tbv_ruta_programada[]) list.toArray(new Tbv_maquina_tbv_ruta_programada[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tbv_maquina_tbv_ruta_programada[] tbv_maquina_tbv_ruta_programadas = listTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy);
		if (tbv_maquina_tbv_ruta_programadas != null && tbv_maquina_tbv_ruta_programadas.length > 0)
			return tbv_maquina_tbv_ruta_programadas[0];
		else
			return null;
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tbv_maquina_tbv_ruta_programada[] tbv_maquina_tbv_ruta_programadas = listTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy, lockMode);
		if (tbv_maquina_tbv_ruta_programadas != null && tbv_maquina_tbv_ruta_programadas.length > 0)
			return tbv_maquina_tbv_ruta_programadas[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_maquina_tbv_ruta_programadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_maquina_tbv_ruta_programadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_maquina_tbv_ruta_programada as Tbv_maquina_tbv_ruta_programada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_maquina_tbv_ruta_programadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_maquina_tbv_ruta_programada as Tbv_maquina_tbv_ruta_programada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada createTbv_maquina_tbv_ruta_programada() {
		return new orm.Tbv_maquina_tbv_ruta_programada();
	}
	
	public boolean save(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().saveObject(tbv_maquina_tbv_ruta_programada);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().deleteObject(tbv_maquina_tbv_ruta_programada);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada)throws PersistentException {
		try {
			if(tbv_maquina_tbv_ruta_programada.getTbv_maquinama_id_maquina() != null) {
				tbv_maquina_tbv_ruta_programada.getTbv_maquinama_id_maquina().tbv_maquina_tbv_ruta_programada.remove(tbv_maquina_tbv_ruta_programada);
			}
			
			if(tbv_maquina_tbv_ruta_programada.getTbv_ruta_programadarp_id_ruta_programada() != null) {
				tbv_maquina_tbv_ruta_programada.getTbv_ruta_programadarp_id_ruta_programada().tbv_maquina_tbv_ruta_programada.remove(tbv_maquina_tbv_ruta_programada);
			}
			
			return delete(tbv_maquina_tbv_ruta_programada);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tbv_maquina_tbv_ruta_programada.getTbv_maquinama_id_maquina() != null) {
				tbv_maquina_tbv_ruta_programada.getTbv_maquinama_id_maquina().tbv_maquina_tbv_ruta_programada.remove(tbv_maquina_tbv_ruta_programada);
			}
			
			if(tbv_maquina_tbv_ruta_programada.getTbv_ruta_programadarp_id_ruta_programada() != null) {
				tbv_maquina_tbv_ruta_programada.getTbv_ruta_programadarp_id_ruta_programada().tbv_maquina_tbv_ruta_programada.remove(tbv_maquina_tbv_ruta_programada);
			}
			
			try {
				session.delete(tbv_maquina_tbv_ruta_programada);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().refresh(tbv_maquina_tbv_ruta_programada);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tbv_maquina_tbv_ruta_programada tbv_maquina_tbv_ruta_programada) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().evict(tbv_maquina_tbv_ruta_programada);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_maquina_tbv_ruta_programada loadTbv_maquina_tbv_ruta_programadaByCriteria(Tbv_maquina_tbv_ruta_programadaCriteria tbv_maquina_tbv_ruta_programadaCriteria) {
		Tbv_maquina_tbv_ruta_programada[] tbv_maquina_tbv_ruta_programadas = listTbv_maquina_tbv_ruta_programadaByCriteria(tbv_maquina_tbv_ruta_programadaCriteria);
		if(tbv_maquina_tbv_ruta_programadas == null || tbv_maquina_tbv_ruta_programadas.length == 0) {
			return null;
		}
		return tbv_maquina_tbv_ruta_programadas[0];
	}
	
	public Tbv_maquina_tbv_ruta_programada[] listTbv_maquina_tbv_ruta_programadaByCriteria(Tbv_maquina_tbv_ruta_programadaCriteria tbv_maquina_tbv_ruta_programadaCriteria) {
		return tbv_maquina_tbv_ruta_programadaCriteria.listTbv_maquina_tbv_ruta_programada();
	}
}
